/*
 * Copyright (c) 2007-2020 西安交通信息投资营运有限公司 版权所有
 */

package com.xci.edu.core.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.github.lvyanyang.core.BaseOperateUserEntity;
import com.github.lvyanyang.core.Const;
import com.github.lvyanyang.core.XCI;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import java.util.Date;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * 培训计划
 * @author 张谦 zhangqian@xci96716.com
 * @since 2020-11-25 09:35:56
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(description = "培训计划")
public class EduPlan extends BaseOperateUserEntity {
    /**
     * 主键
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @ExcelIgnore
    @Excel(name = "主键", width = 20d)
    @ApiModelProperty(value = "主键", position = 1)
    private Long id;

    /**
     * 名称
     */
    @NotBlank(message = "名称不能为空")
    @Length(max = 50, message = "名称长度不能超过{max}个字符")
    @Excel(name = "名称", width = 20d)
    @ApiModelProperty(value = "名称", required = true, position = 2)
    private String name;

    /**
     * 名称简拼
     */
    @Length(max = 50, message = "名称简拼长度不能超过{max}个字符")
    @Excel(name = "名称简拼", width = 20d)
    @ApiModelProperty(value = "名称简拼", position = 3)
    private String spell;

    /**
     * 科目主键
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @NotNull(message = "科目主键不能为空")
    @ApiModelProperty(value = "科目主键", required = true, position = 4)
    private Long eduCategoryId;

    /**
     * 科目名称
     */
    @NotBlank(message = "科目名称不能为空")
    @Length(max = 50, message = "科目名称长度不能超过{max}个字符")
    @Excel(name = "科目名称", width = 20d)
    @ApiModelProperty(value = "科目名称", required = true, position = 5)
    private String eduCategoryName;

    /**
     * 培训讲师
     */
    @Length(max = 50, message = "培训讲师长度不能超过{max}个字符")
    @Excel(name = "培训讲师", width = 20d)
    @ApiModelProperty(value = "培训讲师", position = 6)
    private String teacher;

    /**
     * 培训开始日期
     */
    @NotNull(message = "培训开始日期不能为空")
    @Excel(name = "培训开始日期", width = 20d, exportFormat = Const.DEFAULT_DATE_PATTERN)
    @ApiModelProperty(value = "培训开始日期", required = true, position = 7)
    private Date trainStartDate;

    /**
     * 培训开始日期文本(yyyy-MM-dd)
     */
    @ApiModelProperty(value = "培训开始日期", required = true, position = 7)
    private String trainStartDateText;

    public String getTrainStartDateText() {
        return XCI.formatDate(trainStartDate);
    }

    /**
     * 培训结束日期
     */
    @NotNull(message = "培训结束日期不能为空")
    @Excel(name = "培训结束日期", width = 20d, exportFormat = Const.DEFAULT_DATE_PATTERN)
    @ApiModelProperty(value = "培训结束日期", required = true, position = 8)
    private Date trainEndDate;

    /**
     * 培训结束日期文本(yyyy-MM-dd)
     */
    @ApiModelProperty(value = "培训结束日期", required = true, position = 8)
    private String trainEndDateText;

    public String getTrainEndDateText() {
        return XCI.formatDate(trainEndDate);
    }

    /**
     * 计划人数
     */
    @NotNull(message = "计划人数不能为空")
    @Excel(name = "计划人数", width = 20d)
    @ApiModelProperty(value = "计划人数", required = true, position = 9)
    private Integer planCount;

    /**
     * 已约人数
     */
    @Excel(name = "已约人数", width = 20d)
    @ApiModelProperty(value = "已约人数", required = true, position = 10)
    private Integer useCount;

    /**
     * 状态[1-启用, 0-禁用]
     */
    @Excel(name = "状态", width = 20d, replace = { "启用_1", "禁用_0" })
    @ApiModelProperty(value = "状态[1-启用, 0-禁用]", required = true, position = 11)
    private Integer status;

    /**
     * 状态文本
     */
    @ApiModelProperty(value = "状态文本", position = 12)
    private String statusText;

    /**
     * 状态文本
     */
    public String getStatusText() {
        if(XCI.isEmpty(status)){
            return Const.Empty;
        }
        switch (status) {
            case 0:
                return "禁用";
            case 1:
                return "启用";
        }
        return Const.Empty;
    }

    /**
     * 备注
     */
    @Length(max = 500, message = "备注长度不能超过{max}个字符")
    @Excel(name = "备注", width = 20d)
    @ApiModelProperty(value = "备注", position = 12)
    private String remark;

}